/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cz.muni.fi.veles.polygon;

import cz.muni.fi.veles.AbstractLocation;
import java.util.Collections;
import java.util.List;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.render.Renderer;

/**
 * RendererBase of polygon
 * @author Jan Ferko
 */
@ResourceDependencies({
    @ResourceDependency(name="polygon.js", target="head")
})
public class PolygonRendererBase extends Renderer{

    /**
     * Return key of used map server
     * @param component component which is rendered
     * @return key of used map server
     */
    public String getMapServer(UIComponent component){
        if(component == null || !(component instanceof AbstractPolygon)){
            return "";
        }
       AbstractPolygon polygon = (AbstractPolygon) component;
       return polygon.resolveMapServer().getId();
    }

    /**
     * Path of polygon
     * @param component rendered component
     * @return list of abstract location, which represent path of polygon
     */
    public List<AbstractLocation> getPath(UIComponent component){
        if(component == null || !(component instanceof AbstractPolygon)){
            return Collections.emptyList();
        }
        AbstractPolygon polygon = (AbstractPolygon) component;
        return polygon.getPath();
    }

}
